package club.yuit.desktop.model;

import club.yuit.rmq.ClientServiceProviderFactory;
import club.yuit.rmq.service.ConsumerService;
import lombok.Getter;
import lombok.Setter;
import org.apache.rocketmq.client.apis.consumer.FilterExpression;
import org.apache.rocketmq.client.apis.consumer.FilterExpressionType;

/**
 * @author: yuit
 * @date: 2023/12/12 13:39
 */
@Getter
@Setter
public class ConsumerContext {

    private ConsumerService consumerService;
    private String topic;

    private String messageGroup;

    private FilterExpressionType filterExpressionType;

    private String filterExpression;


    public void setFilterExpressionType(String type) {
        if (type.equals("SQL")) {
            filterExpressionType = FilterExpressionType.SQL92;
        } else {
            filterExpressionType = FilterExpressionType.TAG;
        }
    }

    public FilterExpression getFilterExpression() {
        return new FilterExpression(filterExpression,filterExpressionType);
    }


}
